<template>
  <div class="topdashboard">
    <!-- {{rowData.data}} -->
    <h2>{{ rowData.title }}</h2>
    <!-- <p class="today">今日</p> -->
    <p class="today">&nbsp;</p>
    <div
      class="topM"
      :style="!roleList.SalesConsultant && !roleList.NetSalesManager && !roleList.ShowroomManager?'textAlign:center;':''"
    >
      <div>
        <router-link
          class="topM1"
          :to="{ path: rowData.routerLinkTo, query: { active: 1, time: today, consultant: rowData.consultant } }"
        >{{rowData.sum}}</router-link>/
        <span>
          <router-link
            class="topM1 topM2"
            :to="{ path: rowData.routerLinkTo, query: { active: 2, time: today, consultant: rowData.consultant } }"
          >{{rowData.noNumber}}</router-link>
          {{rowData.introduction}}
        </span>
        <span class="line"></span>
        <router-link
          :to="{ path: rowData.routerLinkTo, query: { active: 3, time: today , consultant: rowData.consultant} }"
          class="topbtmone"
        >
          {{ rowData.progressBarTitle1 }}
          <span class="topM2">{{ rowData.progressBar1 }}</span>
        </router-link>
      </div>
    </div>

    <!-- <div class="topbtm" :style="roleList.SalesConsultant && roleList.ShowroomManager ? 'flexDirection: column;':''">
      <router-link :to="{ path: rowData.routerLinkTo, query: { active: 3, time: today } }" class="topbtmone">
        {{ rowData.progressBarTitle1 }}
        <span style="color:#FF4D4F;">{{ rowData.progressBar1 }}</span>
      </router-link>
      <div class="topbtmone" :style="roleList.SalesConsultant && roleList.ShowroomManager ? '':'textAlign:right;'">
        {{ rowData.progressBarTitle2 }}
        <span style="color:#BAE637;">{{ rowData.progressBar2 }}</span>
      </div>
    </div>
    <div class="tomorrow">
      <span>明日</span><router-link :to="{ path: rowData.routerLinkTo, query: { active: 4, time: tomorrow } }" class="text">{{ rowData.tomorrow }}</router-link>
    </div>-->
    <div class="topbottombox">
      <div class="topbottom">
        <div class="topbottomone">
          <span>明日</span>
          <router-link
            :to="{ path: rowData.routerLinkTo, query: { active: 4, time: tomorrow , consultant: rowData.consultant} }"
            style="color:#2089F9;"
          >{{ rowData.tomorrow }}</router-link>
        </div>
        <div class="topbottomone">
          {{ rowData.progressBarTitle2 }}
          <span style="color:#36CFC9;">{{ rowData.progressBar2 }}</span>
        </div>
        <!-- 进度条 -->
        <div class="progressBar">
          <div class="progressBarl">
            <div class="progressBarn" :style="{'width':progressBar2}"></div>
          </div>
        </div>
      </div>
      <div class="topbottom"></div>

      <!-- <div class="topbottom" style="textAlign:right;">
        <div class="topbottomone">
          <span>首触</span>
          <a style="color:#73D13D;">{{ rowData.firstTouchCount || 0 }}</a>
        </div>
        <div class="topbottomone">
          待定
          <span style="color:#FF7A45;">{{ rowData.judgeCount || 0 }}</span>
      </div>-->
      <!-- 进度条 -->
      <!-- <div class="progressBar">
          <div class="progressBarl progressBarb">
            <div class="progressBarn" :style="{'width':progressBar3}"></div>
          </div>
        </div>
      </div>-->
    </div>
  </div>
</template>

<script>
import moment from 'moment';
export default {
  name: 'topright',
  props: {
    rowData: {
      type: Object,
      default: () => ({})
    },
    roleList: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      today: moment().format('YYYY-MM-DD'),
      tomorrow: moment(new Date())
        .add(1, 'days')
        .format('YYYY-MM-DD')
    };
  },
  computed: {
    progressBar2: function() {
      let tomorrow = this.rowData.tomorrow || 0;
      let progressBar2 = this.rowData.progressBar2 || 1;
      return tomorrow > progressBar2 ? '0%' : Math.round((tomorrow / progressBar2) * 10000) / 100.0 + '%'; // 小数点后两位百分比
    },
    progressBar3: function() {
      let judgeCount = this.rowData.judgeCount || 0;
      let firstTouchCount = this.rowData.firstTouchCount || 1;
      return judgeCount > firstTouchCount ? '0%' : Math.round((judgeCount / firstTouchCount) * 10000) / 100.0 + '%'; // 小数点后两位百分比
    }
  },
  methods: {
    closeDialog() {
      this.$emit('close', false);
    }
  }
};
</script>

<style lang="less" scoped>
.topdashboard {
  min-height: 150px;
  padding: 24px;
  background: #fff;
  border-radius: 2px;
  padding-bottom: 0;
  position: relative;
  &:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  }
  h2 {
    font-weight: 500;
    color: @textColorSecondary;
    line-height: 16px;
  }
  .today {
    margin-top: 16px;
    color: @mostColor;
    // text-align: center;
  }
  .topM {
    font-weight: bold;
    color: @fullColor;
    line-height: 43px;
    font-size: 32px;
    // text-align: center;
    .topM1 {
      color: @fullColor;
      font-weight: 600;
    }
    .topM2 {
      font-size: 15px;
      font-weight: 600;
    }
    span {
      font-size: 12px;
      font-weight: 400;
    }
    .line {
      margin-left: 2px;
      border-left: 1px solid rgba(0, 4, 10, 0.08);
      padding-right: 9px;
    }
    .topM_right,
    .topbtmone {
      font-size: 12px;
      color: @mostColor;
      font-weight: 400;
    }
  }
  .topbtm {
    display: flex;
    margin: 6px 0;
    justify-content: space-between;
    flex-wrap: wrap;
    font-size: 12px;
    line-height: 18px;
    .topbtmone {
      flex: 1;
      flex-basis: auto; //兼容IE
    }
  }
  .tomorrow {
    line-height: 36px;
    font-size: 14px;
    border-top: 2px solid rgba(0, 4, 10, 0.08);
    .text {
      color: rgba(32, 137, 249, 1);
      margin-left: 16px;
    }
  }
  .progressBar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    .progressBarl {
      width: 100%;
      height: 4px;
      border-radius: 2px;
      background-color: rgba(54, 207, 201, 1);
      .progressBarn {
        width: 0%;
        height: 100%;
        border-radius: 2px;
        background: rgba(32, 137, 249, 1);
      }
    }
    .progressBarb {
      background-color: rgba(115, 209, 61, 1);
      .progressBarn {
        background: rgba(255, 122, 69, 1);
      }
    }
  }

  .topbottombox {
    padding: 8px 0 14px 0;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    align-items: center;
    .topbottom {
      flex: 1;
      flex-basis: auto; //兼容IE
      .topbottomone {
        line-height: 26px;
        font-size: 14px;
        color: @textColor;
        .text {
          color: rgba(32, 137, 249, 1);
          margin-left: 8px;
        }
        a,
        span {
          font-size: 14px;
        }
      }
    }
  }
}
</style>
